#ifndef AUDIO_RESAMPLER_H
#define AUDIO_RESAMPLER_H
#include <mutex>
#include <memory>//智能指针库
#include "AVCommon.h"


//音频重采样，音频格式转化为目标格式进行播放
class SwrContext;
class Audio_Resampler
{
public:
    Audio_Resampler();
    ~Audio_Resampler();

public:
    //in_samplerate 原始采样率 out_samplerate目标采样率
    bool OPen(int in_samplrate,int in_channels,AVSampleFormat in_format,
              int out_samplerate,int out_channels,AVSampleFormat out_format);
    //
    int Covert(AVFramePtr in_frame,AVFramePtr& out_frame);

protected:
    void   close();

private:
    int in_samplerate_ = 0;//输入采样率
    int in_channles_ = 0;//输入音频通道数
    AVSampleFormat in_format_ = AV_SAMPLE_FMT_NONE;


    int out_samplerate_ = 0;//输出采样率
    int out_channles_ = 0;//输出音频通道数
    AVSampleFormat out_format_ = AV_SAMPLE_FMT_NONE;

    SwrContext* swr_Context_ = nullptr;
};

#endif // AUDIO_RESAMPLER_H
